<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商家</title>
    <script src="js/sethtmlfontSize.js"></script>
    <link rel="icon" href="./images/logo.ico" />
    <link rel="stylesheet" href="./css/shop.css">
    <link rel="stylesheet" href="./css/common.css"> 
    <link rel="stylesheet" href="./css/searchhead.css">  
    <link rel="stylesheet" href="./css/idangerous.swiper.css">
</head>
<body>
    <header class="searchs">
        <div class="search-left">
            <i></i>
        </div>
        <div class="search-center">
            <span class="center-span">商家</span>
            <div class="clears"></div>
            <img class="seacher-img" src="images/triangle_icon_search.png" alt="">
             <input id="search-input" type="text" autofocus>
 
          <div id="classify">
               <i></i>
               <ul class="c-ul">
                   <li><a data-link="goods" href="javascript:void(0)"><img class="classify-img" src="images/goods_icon_search.png" alt=""><span class="classify-span">商品</span></a></li>
                   <li><a data-link="shop" href="javascript:void(0)"><img class="classify-img" src="images/shop_icon_search.png" alt=""><span class="classify-span">商家</span></a></li>
                   <li><a data-link="service" href="javascript:void(0)"><img class="classify-img" src="images/fuwu_icon_search.png" alt=""><span class="classify-span">服务</span></a></li>
               </ul>
           </div>           
        </div>
        <div class="search-right">
           <span id="collect" class="collect"> 搜索</span>
        </div>
        <div class="clears"></div>     
        <div class="object1"></div>
        
    </header>
    <div class="shop-page">
        <div class="shops-banner swiper-container">
             <div class="zwl-shopDetail swiper-wrapper">
                  <div class="swiper-slide">
                    <ul class="zwl-goodUl">

                    </ul>
                  </div>
                  <div class="swiper-slide">
                    <ul class="zwl-goodUl">

                    </ul>
                  </div>
             </div>
             <div class="pagination"></div>   
        </div>
         <!--附近商品-->
        <div class="nears-bg">
            <span>附近商家</span>
        </div>
        <div id="detail">    
        </div>
        <div class="clears"></div>
            <!--正在加载中-->
        <div class="data-loading">滚动加载</div>
    </div>
         <!--底部-->
    <footer id="footer" class="footer">
        <div class="pagenum" style="visibility:hidden;">
            <span class="pre">上一页</span>
            <i idaccesskey="currentpage" class="currentpage">2</i>
            <span class="next">下一页</span>   
        </div>
        <div class="footer-ul">
           <ul>
               <li class="first"><a href="./index.html">首页</a></li>
               <li class="li login"><a href="javascript:void(0);">登录</a></li>
               <li class="li"><a href="http://www.shidiquan.cn/indexPhone.html">客户端</a></li>
               <li class="li"><a href="javascript:void(0);">电脑版</a></li>
               <li class="li"><a href="http://www.shidiquan.cn">帮助</a></li>
           </ul>
       </div>
    </footer>
    <!--悬浮下载app-->
    <div id="download-app" class="download-app">
        <div id="down-content" class="down-content">
            <img class="close" id="close" src="./images/close_icon.png" alt="">
            <div class="down-left l">
                <img src="./images/logo.png" alt="">
            </div>
            <div class="down-center l">
                <p class="unmgntop">下载实地圈客户端</p>
                <p class="mgntop">兼职推广，在家创业，躺着赚钱</p>
            </div>
            <div class="down-right l">
                <span class="">免费下载</span>
            </div>
            <div class="clears"></div>
        </div>
    </div>
    <!--回到顶部-->
    <div id="back-top" class="back-top">
        <img src="./images/back_top_icon.png" alt="回到顶部">      
    </div>
</body>
<script src="./js/jquery-1.7.2.min.js"></script>
<script src="./js/pub_page.js"></script>
<script src='./js/idangerous.swiper.min.js'></script>
<script>
    $(function(){
        $(".search-center .center-span,.search-center .seacher-img").on("click",function(){
            $("#classify").toggle();
        }); 
        var currentCity=SYS_GLOBAL_CONFIG.getCurrentCity("currentCity");
        var l_s;
        if(window.localStorage){
            l_s=window.localStorage;      
        }else{
            l_s={};
        }
        //点击搜索框，进行搜索
        $("#search-input").on("click",function(){
            l_s.search_state=1;
            location.href="./searchShop.html?currentCity="+currentCity;
    });
    $(".c-ul li").on("click",function(){
        var links=$(this).find("a").attr("data-link");
        location.href="./"+links+".html?currentCity="+currentCity;
    });   
        var address=""||currentCity;
        var sellerType="";
        var requestData1="";
        var requestData2="";
        var requestData3="";
        var url=SYS_GLOBAL_CONFIG.reqUrl,
        async=true,
        type="post";
        var currentPage=1;//默认设置当前页为第一页
        var totalPage=1;//设置默认总页数
        var show_count=5;//设置默认每次加载的条数
        var requestData=JSON.stringify({
            "code":"getShopList",
            "verson":"1.0",
            "data":{
                "salesManId":"",
                "address":address,
                "sellerType":"",
                "resType":"1",
                "currentPage":currentPage,
                "showCount":show_count
            }
        });
        console.log(requestData);
        //获取全部的类型
        var allProduct=JSON.stringify({
            "code":"getPdOrServTypeList",
            "version":"1.0",
            "data":{
                "parentServiceId":0,
                "type":"PRODUCT",
                "parentPdTypeId":0
            }
        });      
    getData(url,requestData,handdle_func1,async,type);
    function getData(url,datas,call_func,async,type){
        console.log("请求参数:"+datas);
        $.ajax({
            url:url,
            type:type,
            datatype:"json",
            async:async,
            contentType:"application/json",
            data:datas,
            success:function(data){
                call_func(data);
            },
            error:function(){
                console.log("失败-----------");
            }   
        });        
    }  
        $(".shop-sort").on("click",function(){
            sellerType=$(this).attr("data-salesId");
            $("#detail").html("");
            currentPage=1;
            requestData1=JSON.stringify({
                "code":"getShopList",
                "verson":"1.0",
                "data":{
                    "salesManId":"",
                    "address":address,
                    "sellerType":sellerType,
                    "currentPage":currentPage,
                    "showCount":show_count
                }
            });
            getData(url,requestData1,handdle_func1,async,type);
        });
        function handdle_func1(data){
            var dataS=data.data.datas;
            var s_len=dataS.length;
            var img="";
            var registr="";
            var attr="";
            totalPage=data.data.totalPage;
            var li="";
            var downS='';
            for(var i=0;i<s_len;i++){
                if(dataS[i].seller){
                    if(dataS[i].seller.isSellerAuth=="1"){
                        img='<img class="img3" src="./images/vip_icon.png" alt="">';
                        registr="(已认证)";
                    }else{
                        img="";
                        registr="(未认证)";
                    }    
                }
                var tagStr='';
                var tagS='';
                if(dataS[i].sellerFees){
                    if(dataS[i].sellerFees.length>0){
                        console.log(dataS[i].sellerFees.length);
                        if(dataS[i].sellerFees.length>0){
                            var SellerFree=dataS[i].sellerFees[0].isAvaliable;
                            if(SellerFree=="1"){//已开通增值服务
                                var s_tag=dataS[i].tagServices;
                                var ss_len=s_tag.length;
                                if(ss_len>2){
                                    downS='<i class="down"></i>';
                                }
                                for(var s=0;s<ss_len;s++){
                                    tagStr+='<p class="tags_info"><img src="'+s_tag[s].tagIconPath+'" alt=""><span>'+s_tag[s].userRemark+'</span></p>';
                                    if(s<3){
                                        tagS+='<span>'+s_tag[s].name+'</span>';
                                    }
                                }        
                            }       
                        }
                    }    
                }

               li+='<div class="detail-shop" data-shopId="'+dataS[i].shopId+'">'+
                    ' <img class="img2" src="'+dataS[i].logoImgPath+'" alt="">'+
                    '<div class="introduce">'+
                    ' <div class="introduce-detail">'+
                    '<div class="introduce-name">'+
                    '<span class="span-detail"><span class="span-name">'+dataS[i].shopName+'</span>'+ 
                    ''+img+'</span><p class="span-tags">'+tagS+'</p>'+
                    ' <span class="cess r1">'+dataS[i].shopTypeName+'</span><span class="regstr r1">'+registr+'</span> </div>'+
                    '<div class="clears"></div></div></div><div class="clears"></div><div class="zwl-benefit max2_h">'+tagStr+downS+'</div></div>';
            }
            $("#detail").append(li);
            var down_flag=1;
            if(downS!=''){
                $(".zwl-benefit i").off("click");
                $(".zwl-benefit i").on("click",function(){
                    if(down_flag==1){  
                        $(this).addClass("up").removeClass("down").parent(".zwl-benefit").addClass("auto_h").removeClass("max2_h");
                        down_flag=0;
                    }else{
                        $(this).addClass("down").removeClass("up").parent(".zwl-benefit").addClass("max2_h").removeClass("auto_h");
                        down_flag=1;
                    }
                });    
            }
            $(".detail-shop .img2,.detail-shop .introduce").on("click",function(){
                var shopId =$(this).parent(".detail-shop").attr("data-shopId");
                url = "shopDetail.html?shopId="+shopId;//此处拼接内容
                location.href = url;
            });
        }
        //获取全部商品，商铺类      
        function call_func2(data){
            console.log(data);
            var list=data.data.productTypes;
            var listLen=list.length;
            var count=Math.ceil(listLen/12);//页数 12为每页显示的个数
            var dataStr="";
            var li="";
            for(var j=0;j<count;j++){
                var dataS="";
                for(var i=j*12;i<(j+1)*12;i++){
                    if(i==listLen){
                      
                        break;
                    }
                    dataS+=' <li class="goodType" data-typeId="'+list[i].pdTypeId+'"><a href="shop-classify.html?pdTypeId='+list[i].pdTypeId+'"><img src="'+list[i].iconPath+'" alt=""></a><p>'+list[i].pdTypeName+'</p></li>';
                }
                li+='<div class="swiper-slide"><ul class="zwl-shopUl l">'+dataS+'</ul></div>';   
            }
            $(".zwl-shopDetail").html(li);
            
    }
    //获取全部产品类
    getData(url,allProduct,call_func2,async,type);
    var current_Page=1;
    /**
     *滚动加载更多*
     **/
    $(window).scroll(function(){
        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop())-400;
        $(".data-loading").removeClass("hide").addClass("show");
        if((parseFloat($(document).height())-400)<=totalheight){
            console.log(totalPage+"---"+current_Page);
            if(totalPage>current_Page){
                current_Page+=1;
                var data_p=JSON.stringify({
                    "code":"getShopList",
                    "verson":"1.0",
                    "data":{
                        "salesManId":"",
                        "address":address,
                        "sellerType":"",
                        "resType":"1",
                        "currentPage":current_Page,
                        "showCount":show_count
                    }
                });
                console.log(data_p);
                getData(url,data_p,handdle_func1,async,type);    
            }else{
                $(".data-loading").html("已加载全部");
            }
        }
     });
});  
</script>
<script>
    var mySwiper = new Swiper ('.swiper-container',{
    pagination: '.pagination',
    paginationClickable: true
  });
</script>
</html>
